home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Today - The Disc! 5
/
CD-ROM Today - The Disc (Issue 5)(November 1994).ISO
/
mac
/
Mac shareware
/
Education
/
RLaB
/
help
/
STRING
< prev
next >
Wrap
Text File
|
1994-09-21
|
2KB
|
69 lines
STRING:
Strings are the equivalent of C string constants (or string
literals). Strings are entered from the command line like:
> str = "Sample String"
Sample String
The show command reveals the attributes associated with each
string.
> show ( str )
name: str
class: string
type:
nr: 1
nc: 1
The information can also be obtained, by referencing the
object members.
> str.class
string
> str.l
13
Strings are always enclosed in `"'. Single quotes, either
forward or backward have no special meaning in RLaB.
Strings can contain escape characters;
`\n' newline
`\t' tab
`\f' formfeed
`\b' backspace
`\r' carriage return
`\a' alert (bell)
`\v' vertical tab
`\\' backslash
`\'' single quote
`\"' double quote
Strings can be concatenated using the addition operator (`+').
Since you cannot break a string across lines you can:
"Entering a really long string, with more to go. " + ...
"Now type in the rest of it... "
The above will produce a single string.
Strings can be used to form matrices, in the same way the
numeric values can form a numeric matrix:
> strm = [ "str11", "str12";
> "str21", "str22"]
strm =
str11 str12
str21 str22
The elements of a string matrix do not need to be the same
length. The output from what() is a good example.
Scalar strings cannot be mixed with numeric scalars in the
same matrix. Lists provide a good method of mixing string and
numeric data.
The built-in function strsplt() is provided to split a string
scalar into individual characters.